<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="../assets/js/vue.js"></script>
    <title>实例入门-实例方法</title>
</head>
<body>
<h1>实例入门-实例方法</h1>
<hr>
<div id="app">
    {{message}}
</div>
<p>
    <button onclick="destroy()">卸载</button>
</p>
<p>
    <button onclick="reload()">更新</button>
</p>
<p>
    <button onclick="tick()">更新</button>
</p>

<script type="text/javascript">
    var jspang = Vue.extend({
        template: `<p>{{message}}</p>`,
        data: function () {
            return {
                message: 'Hello ,I am JSPang'
            }
        },
        mounted: function () {
            console.log('mounted被创建');
        },
        destroyed: function () {
            console.log('mounted被销毁');
        },
        updated: function () {
            console.log('mounted已经更新');
        }
    });
    var vm = new jspang().$mount("#app");
    function destroy() {
        vm.$destroy();
    }
    function reload() {
        vm.$forceUpdate();
    }
    function tick() {
        vm.message = "update message info ";
        vm.$nextTick(function () {
            console.log('message更新完后我被调用了');
        })
    }
</script>
</body>
</html>